/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jpa.session;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import jpa.entities.Usuario;

/**
 *
 * @author jordan
 */
@Stateless
public class UsuarioFacade extends AbstractFacade<Usuario> {
    @PersistenceContext(unitName = "ColetaSeletivaAuto2PU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UsuarioFacade() {
        super(Usuario.class);
    }
    public Usuario buscarLogin(String login)
    {
        Usuario usuario = null;
        try 
        {
            usuario = (Usuario) em.createNamedQuery("Usuario.findByLogin")
            .setParameter("login", login)
            .getSingleResult();
        } catch (Exception e) 
        {
            return null;
        }
        return usuario;
}
    
}
